<?php
declare (strict_types = 1);

namespace app\admin\controller;

use think\facade\View;
use think\Request;

class Manager
{
    /**
     *
     */
    public function list(){

        # 查询数据

        # 接收查找的条件
        $username = \request()->get('username');

//        if (!empty($username)) {
//            $data = \app\admin\model\Manager::where('username','like',"%$username%")->paginate(3);
//        } else {
//            $data = \app\admin\model\Manager::paginate(3);
//        }

        # 保留搜索条件分页
        $where = [];
        if (!empty($username)) {
            $where[] = ["username",'like',"%$username%"];
        }

        $data = \app\admin\model\Manager::where($where)->paginate([
            'list_rows' => 3,
            'query' => [
                'username' => $username
            ],
        ]);


        View::assign('data',$data);
        View::assign('username',$username);
        return View::fetch('/manager_list');
    }
}
